
using System;
using System.Collections.Generic;
using Banshee.Base;
using Banshee.Widgets;
using Banshee.Sources;

using Gtk;
using Gdk;
using GLib;

namespace Banshee.Plugins.iTunesImporter
{
	internal class SummarySource : Banshee.Sources.ChildSource
	{
		private SummaryWidget viewWidget;
		private uint ratings, stats, playlists, splaylists;
		private List<SmartPlaylist> partial, failed;
		private bool interrupted;
		
		public override string UnmapLabel
		{
            get { return "Remove"; }
        }
        public override string GenericName
        {
            get { return "Import Summary"; }
        }
        public override bool SearchEnabled
        {
            get { return false; }
        }
        public override Pixbuf Icon {
        	get { return Gtk.IconTheme.Default.LoadIcon("gtk-dialog-info", 18, 0); }
        }
		
		public SummarySource(uint ratings,
							uint stats,
							uint playlists,
							uint splaylists,
							List<SmartPlaylist> partial,
							List<SmartPlaylist> failed,
							bool interrupted
							) : base("Import Summary", 1)
		{
			this.ratings = ratings;
			this.stats = stats;
			this.playlists = playlists;
			this.splaylists = splaylists;	
			this.partial = partial;
			this.failed = failed;
			this.interrupted = interrupted;
		}
		
		public override void Activate()
        {
        	viewWidget = new SummaryWidget();
        	viewWidget.UnmapDel = delegate () { Unmap(); };
        	viewWidget.Ratings = ratings;
        	viewWidget.Stats = stats;
        	viewWidget.Playlists = playlists;
        	viewWidget.SPlaylists = splaylists;
        	viewWidget.Partial = partial;
        	viewWidget.Failed = failed;
        	viewWidget.Interrupted = interrupted;
        	viewWidget.Initialize();
         }
        
        public override Widget ViewWidget
        {
            get { return viewWidget; }
        }
        
        public override void Deactivate()
        {
            viewWidget = null;
            Commit();
        }
		
		public override bool Unmap()
        {
        	SourceManager.RemoveSource(this);
        	return true;
        }
	}
}
